﻿@model SecurityAdmin.Web.Models.AddUserClaimViewModel

@{var seesionVar = Session["SELECTED-USER"] as SecurityApi.DataAccess.User;}

@{
    Layout = "~/Views/Shared/_LayoutManageUser.cshtml";
}

<h3>ADD USER CLAIMS:  @seesionVar.UserName</h3>

@using (Html.BeginForm())
{
   <table>
       <tr>
           <td>
               @(Html.Kendo().DropDownList()        
                                    .Name("ResourceId") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget.        
                                    .HtmlAttributes(new { style = "width:300px;" })
                                    .DataTextField("Name") //Specifies which property of the Product to be used by the dropdownlist as a text.        
                                    .DataValueField("ResourceId") //Specifies which property of the Product to be used by the dropdownlist as a value.        
                                    .DataSource(source =>         
                                        {                
                                            source.Read(read =>               
                                            {
                                                read.Action("AjaxGetResouceList", "Resource"); //Set the Action and Controller name                            
                                            });        
                                        })        
                                        )                    
           </td>
           <td>
                <button name="button">Refresh</button>
           </td>
       </tr>
   </table> 

    
<p></p>    
    
@(Html.Kendo().Grid<SecurityApi.DataAccess.ClaimType>()
    .Name("AvailableClaimsGrid")
    .HtmlAttributes(new { style = "height:500px;" }) 
    .Columns(columns =>
    {
                                
        //If your grid is ajax bound. You should also define a ClientTemplate for all template columns:
        columns.Template(@<text>
            @Html.ActionLink("Add", "AddUserClaim", "UserClaim", new { claimTypeId = @item.ClaimTypeId, resourceId=@Model.ResourceId})  
            </text>)
        .ClientTemplate("<a href='" + Url.Content("~/UserClaim/AddUserClaim/?") + "claimTypeId= #= ClaimTypeId #'" + ">Add</a>") //always use Url.Content to get the correct relative path
        .Title("View").Width(70);
                                
        columns.Bound(c => c.Name).Width(100);
        columns.Bound(c => c.Uri);
    })
    .Pageable()
    .Sortable()
    .Selectable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Filterable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(p => p.ClaimTypeId))
        .PageSize(50)
        .Read(read => read.Action("AjaxGetAvailableClaims", "UserClaim", new {userId=@seesionVar.UserId}))
    )
)

}